package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.SensitiveDto;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.WmSensitiveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
@Slf4j
public class SensitiveController {

    @Autowired
    private WmSensitiveService sensitiveService;

    @PostMapping("/list")
    public ResponseResult list(@RequestBody SensitiveDto dto){
        log.info("dto:{}",dto);
        return sensitiveService.listByDto(dto);
    }

    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmSensitive sensitive){
        return sensitiveService.saveOrUpdateOne(sensitive);
    }

    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmSensitive sensitive){
        return sensitiveService.saveOrUpdateOne(sensitive);
    }

    @DeleteMapping("/del/{id}")
    public ResponseResult delete(@PathVariable("id") Integer id){
        return sensitiveService.delete(id);
    }

}
